import 'package:flutter/material.dart';
import 'dart:async';

class BottomSheetDemo extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => BottomSheetDemoState();
}

class BottomSheetDemoState extends State<BottomSheetDemo> {
  final bottomSheetGlobalKey = GlobalKey<ScaffoldState>();

  _showBottomSheet() {
    bottomSheetGlobalKey.currentState
        .showBottomSheet((BuildContext context) => BottomAppBar(
              child: Container(
                alignment: Alignment.center,
                height: 90,
                width: double.infinity,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Icon(Icons.access_alarm),
                    Text('12:48 3/3/2019'),
                    Expanded(
                      child: Text(
                        'wake up now',
                        textAlign: TextAlign.right,
                      ),
                    )
                  ],
                ),
              ),
            ));
  }

  Future _showModalBottomSheet() async {
    final options = await showModalBottomSheet(
        context: context,
        builder: (BuildContext context) => Container(
              height: 200,
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  ListTile(
                    title: Text('Option A'),
                    onTap: () {
                      Navigator.of(context).pop('A');
                    },
                  ),
                  ListTile(
                    title: Text('Option B'),
                    onTap: () {
                      Navigator.of(context).pop('B');
                    },
                  ),
                  ListTile(
                    title: Text('Option C'),
                    onTap: () {
                      Navigator.of(context).pop('C');
                    },
                  )
                ],
              ),
            ));

    print(options);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: bottomSheetGlobalKey,
      appBar: AppBar(
        elevation: 0.0,
        title: Text('BottomSheetDemo'),
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                FlatButton(
                    color: Colors.blue,
                    onPressed: _showBottomSheet,
                    textColor: Colors.white,
                    child: Text('_showBottomSheet')),
                SizedBox(
                  width: 16.0,
                ),
                FlatButton(
                    color: Colors.blue,
                    onPressed: _showModalBottomSheet,
                    textColor: Colors.white,
                    child: Text('_showModalBottomSheet'))
              ],
            )
          ],
        ),
      ),
    );
  }
}
